热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CompatibilityIssueswith`disallowAnonymousFunctions`and`esnext`

Thisarticlediscussestheincompatibilityissuesencounteredwhenusing`disallowAnonymousFunctions`and`esnext`together,particularlyinthecontextofmodernJavaScriptcodingpractices.

Hello,

I am encountering an issue where `esnext` and `disallowAnonymousFunctions` settings are not working well together. Specifically, I have both `esnext` and `disallowAnonymousFunctions` set to `true` in my configuration. Here is the code snippet causing the problem:

class Test {
    constructor(first, last) {
        this.first = first;
        this.last = last;
    }

    getName() {
        return `${this.first} ${this.last} is a name.`;
    }
}

When running the linter, I receive two errors stating that 'Anonymous functions need to be named.' These errors are pointing to the positions between the `constructor` keyword and the opening parenthesis, as well as between the `getName` method and its opening parenthesis.

This issue seems to stem from the `disallowAnonymousFunctions` rule being overly strict with modern ES6+ syntax, which often uses concise method definitions without explicit function names. To resolve this, you might consider adjusting the rule or using a different linter configuration that better supports ES6+ features while maintaining code quality standards.

For further assistance, you can post a bounty on this issue via Bountysource. This issue is sourced from the open-source project: jscs-dev/node-jscs. At this point, only major and CST-related bugs will be fixed.


推荐阅读
author-avatar
别装了gg_925
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有